import { Login } from "@/api/interface/index";
import http from "@/api";
import { useUserStore } from "@/stores/modules/user";
/**
 * @name 登录模块
 */
// 用户登录
export const loginApi = (params: Login.ReqLoginForm) => {
  return http.post<Login.ResLogin>(`MasterBaseUsers/Validata`, params, { noLoading: true });
};

// 获取菜单列表(带权限)
export const getAuthMenuListApi = () => {
  return http.get("MasterPermission/GetUserPermissionMenus", {}, { noLoading: true });
};
// 获取菜单列表(不带权限)主要用于菜单管理显示全部菜单
export const getMenuList = () => {
  return http.get("SysBaseTree/GetMenusTree", {}, { noLoading: true });
};
//  获取所有用户信息
export const getAllUserInfo = () => {
  const userStore = useUserStore();
  return new Promise<void>((resolve, reject) => {
    http.get("MasterBaseUsers/Get", {}, { noLoading: true }).then(res => {
      userStore.SetUserList(res.List);
      resolve();
    });
  });
};
